package lee.study.Data_Struct.ClassCompare;

class Student implements Comparable<Student> {//<>中存放的是要比较的类型，然后需要重写compareTo方法
    public int age;
    public int score;
    public String name;

    public Student(int age, int score, String name) {
        this.age = age;
        this.score = score;
        this.name = name;
    }

    @Override
    //缺点：每次业务不同 ，需要去修改类本身。
    //重点：为什么要让类实现可比较的功能呢？
    //为了在创建该类的数组时，能够使用sort等方法。
    public int compareTo(Student o) {
        //return this.age - o.age;根据年龄比较
        return this.score - o.score;
    }
}

public class studentEquals {
    public static void main(String[] args) {
        Student student = new Student(17, 89, "lee");
        Student student1 = new Student(19, 99, "shi");
    }
}
